import requests
r = requests.get("http://www.techlabplt.com:8080/BD-PC/static.html")
r.encoding='utf-8'
         demo = r.text
from bs4 import BeautifulSoup
soup = BeautifulSoup(demo,"html.parser")
# 下行遍历
print(soup.head)
# 遍历head标签的子节点
print(soup.head.contents)
# 遍历body标签的子节点
print(soup.body.contents)
# 输出 body 标签的子节点的数量
print(len(soup.body.contents))
# 使用列表类型的下标来查看 body 的相关子节点
print(soup.body.contents[1])
# .children和.descendants返回的是迭代器类型，可以for…in…的循环结构进行查看。
i = 1
for child in soup.body.children:
    print(str(i)+".", end="")
    print(child)
    i += 1

i = 1
for child in soup.body.descendants:
    print(str(i)+".", end="")
    print(child)
    i += 1
